package rm.ep.shared;


import com.googlecode.objectify.annotation.Unindexed;


@SuppressWarnings("serial")
public class BarrierEntity extends AbstractEntity {

	// initially it is inactive
	private Boolean fIsActive;
	
	private Boolean fIsVisible;
	
	@Unindexed
	private String fEmail;
	
	private String fType;
	
	@Unindexed
	private String fBrief;
	
	@Unindexed
	private Long fFileEntityId;
	
	protected BarrierEntity() {
		// GWT required empty constructor
	}
	
	public BarrierEntity(String email, String type, String brief, Long fileEntityId) {
		if (email == null || !Validator.isEmail(email)) {
			throw new IllegalArgumentException("Invalid Email.");
		}
		if (type == null || type.length() < 3) {
			throw new IllegalArgumentException("Invalid Type.");
		}
		if (brief == null || brief.length() < 100) {
			throw new IllegalArgumentException("Invalid Brief.");
		}
		if (fileEntityId == null || fileEntityId.longValue() < 0) {
			throw new IllegalArgumentException("Invalid File.");
		}
		fEmail = email.toLowerCase();
		fType = type.toUpperCase();
		fFileEntityId = fileEntityId;
		fIsActive = Boolean.TRUE;
		fIsVisible = Boolean.TRUE;
	}
	
	public final Boolean isActive() {
		return fIsActive;
	}
	
	public final void setActive(Boolean isActive) {
		if (isActive)
		fIsActive = isActive;
	}
	
	public final Boolean isVisible() {
		return fIsVisible;
	}
	
	public final void setVisible(Boolean isVisible) {
		fIsVisible = isVisible;
	}
	
	public final String getEmail() {
		return fEmail;
	}
	
	public final String getType() {
		return fType;
	}
	
	public final String getBrief() {
		return fBrief;
	}
	
	public final Long getFileEntityId() {
		return fFileEntityId;
	}
	
}
